package operators;

public class RelationalOperators {
    public static void main(String[] args) {
        int x = 10;
        int y = 20;

        // 基本关系运算
        boolean isEqual = (x == y);        // 等于: false
        boolean notEqual = (x != y);       // 不等于: true
        boolean greaterThan = (x > y);     // 大于: false
        boolean lessThan = (x < y);        // 小于: true
        boolean greaterOrEqual = (x >= y); // 大于等于: false
        boolean lessOrEqual = (x <= y);    // 小于等于: true

        System.out.println("x == y: " + isEqual);
        System.out.println("x != y: " + notEqual);
        System.out.println("x > y: " + greaterThan);
        System.out.println("x < y: " + lessThan);
        System.out.println("x >= y: " + greaterOrEqual);
        System.out.println("x <= y: " + lessOrEqual);

        // 比较字符串（注意：字符串比较应使用equals()方法）
        String str1 = "Hello";
        String str2 = "Hello";
        String str3 = new String("Hello");

        System.out.println("str1 == str2: " + (str1 == str2));      // true（指向同一对象）
        System.out.println("str1 == str3: " + (str1 == str3));      // false（不同对象）
        System.out.println("str1.equals(str3): " + str1.equals(str3));  // true（内容相同）
    }
}
